package com.t.bricks.bussiness.db.entity.recharge.base;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;

import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;

import org.springframework.format.annotation.DateTimeFormat;

import com.t.bricks.annotation.DataInfo;
import com.t.bricks.utils.function.data.MoneyUtil;
import com.t.bricks.utils.function.date.TimeUtil;
import com.t.bricks.utils.function.encode.MD5Util;

/**
 * 充值管理'Recharge'表实体类
 * 警告:非数据库字段禁止在此添加,应该创建扩展实体中添加
 * @author HuangXinBian
 */
@ApiModel("充值管理Recharge")
@DataInfo(sDbName="BricksMall", sTableName="Recharge")
public class RechargeBase implements Serializable {

	private static final long serialVersionUID = 1L;// 使用rmi时需修改

	/**
	 * 记录编号
	 */
	//[start]
	@DataInfo( sDbName="BricksMall", sTableName="Recharge",
		sName="uId", sComment="记录编号", isDbField=true, sDbFileType="varchar",
		sDefaultData="", isExtra=false, iskey=true, isNull=false,
		iMaxLength=32, isDecimal=false, iIntegralLength=2, iDecimalLength=2, iIndex=0 )
	@ApiModelProperty(value="记录编号", example="", position=0)
	//[end]
	protected String uId;

	/**
	 * 顾客编号
	 */
	//[start]
	@DataInfo( sDbName="BricksMall", sTableName="Recharge",
		sName="sCustomerId", sComment="顾客编号", isDbField=true, sDbFileType="varchar",
		sDefaultData="", isExtra=false, iskey=false, isNull=false,
		iMaxLength=32, isDecimal=false, iIntegralLength=2, iDecimalLength=2, iIndex=1 )
	@ApiModelProperty(value="顾客编号", example="", position=1)
	//[end]
	protected String sCustomerId;

	/**
	 * 微信公共号
	 */
	//[start]
	@DataInfo( sDbName="BricksMall", sTableName="Recharge",
		sName="sOpenid", sComment="微信公共号", isDbField=true, sDbFileType="varchar",
		sDefaultData="", isExtra=false, iskey=false, isNull=false,
		iMaxLength=32, isDecimal=false, iIntegralLength=2, iDecimalLength=2, iIndex=2 )
	@ApiModelProperty(value="微信公共号", example="", position=2)
	//[end]
	protected String sOpenid;

	/**
	 * 充值订单号
	 */
	//[start]
	@DataInfo( sDbName="BricksMall", sTableName="Recharge",
		sName="sOrderNo", sComment="充值订单号", isDbField=true, sDbFileType="varchar",
		sDefaultData="", isExtra=false, iskey=false, isNull=false,
		iMaxLength=50, isDecimal=false, iIntegralLength=2, iDecimalLength=2, iIndex=3 )
	@ApiModelProperty(value="充值订单号", example="", position=3)
	//[end]
	protected String sOrderNo;

	/**
	 * 下单IP
	 */
	//[start]
	@DataInfo( sDbName="BricksMall", sTableName="Recharge",
		sName="sSpbillCreateIp", sComment="下单IP", isDbField=true, sDbFileType="varchar",
		sDefaultData="", isExtra=false, iskey=false, isNull=true,
		iMaxLength=18, isDecimal=false, iIntegralLength=2, iDecimalLength=2, iIndex=4 )
	@ApiModelProperty(value="下单IP", example="", position=4)
	//[end]
	protected String sSpbillCreateIp;

	/**
	 * 订单描述
	 */
	//[start]
	@DataInfo( sDbName="BricksMall", sTableName="Recharge",
		sName="sBody", sComment="订单描述", isDbField=true, sDbFileType="varchar",
		sDefaultData="", isExtra=false, iskey=false, isNull=true,
		iMaxLength=200, isDecimal=false, iIntegralLength=2, iDecimalLength=2, iIndex=5 )
	@ApiModelProperty(value="订单描述", example="", position=5)
	//[end]
	protected String sBody;
	
	/**
	 * 价格(元)
	 */
	//[start]
	@DataInfo( sDbName="BricksMall", sTableName="Recharge",
		sName="mFund", sComment="价格(元)", isDbField=true, sDbFileType="decimal",
		sDefaultData="0.00", isExtra=false, iskey=false, isNull=false,
		iMaxLength=10, isDecimal=false, iIntegralLength=6, iDecimalLength=2, iIndex=6 )
	@ApiModelProperty(value="价格(元)", example="0.00", position=6)
	//[end]
	protected BigDecimal mFund;

	/**
	 * 积分
	 */
	//[start]
	@DataInfo( sDbName="BricksMall", sTableName="Recharge",
		sName="iTally", sComment="积分", isDbField=true, sDbFileType="int",
		sDefaultData="0", isExtra=false, iskey=false, isNull=false,
		iMaxLength=100, isDecimal=false, iIntegralLength=2, iDecimalLength=2, iIndex=7 )
	@ApiModelProperty(value="积分", example="0", position=7)
	//[end]
	protected Integer iTally;

	/**
	 * 备注
	 */
	//[start]
	@DataInfo( sDbName="BricksMall", sTableName="Recharge",
		sName="sMemo", sComment="备注", isDbField=true, sDbFileType="varchar",
		sDefaultData="", isExtra=false, iskey=false, isNull=true,
		iMaxLength=200, isDecimal=false, iIntegralLength=2, iDecimalLength=2, iIndex=8 )
	@ApiModelProperty(value="备注", example="", position=8)
	//[end]
	protected String sMemo;

	/**
	 * 创建人
	 */
	//[start]
	@DataInfo( sDbName="BricksMall", sTableName="Recharge",
		sName="sCreator", sComment="创建人", isDbField=true, sDbFileType="varchar",
		sDefaultData="00000000", isExtra=false, iskey=false, isNull=false,
		iMaxLength=32, isDecimal=false, iIntegralLength=2, iDecimalLength=2, iIndex=9 )
	@ApiModelProperty(value="创建人", example="00000000", position=9)
	//[end]
	protected String sCreator;

	/**
	 * 创建日期
	 */
	@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")//解决表单提交时字符串时间值错误
	//[start]
	@DataInfo( sDbName="BricksMall", sTableName="Recharge",
		sName="dCreateDate", sComment="创建日期", isDbField=true, sDbFileType="datetime",
		sDefaultData="", isExtra=false, iskey=false, isNull=false,
		iMaxLength=23, isDecimal=false, iIntegralLength=-1, iDecimalLength=-1, iIndex=10 )
	@ApiModelProperty(value="创建日期", example="", position=10)
	//[end]
	protected Date dCreateDate;

	/**
	 * 修改人
	 */
	//[start]
	@DataInfo( sDbName="BricksMall", sTableName="Recharge",
		sName="sModifieder", sComment="修改人", isDbField=true, sDbFileType="varchar",
		sDefaultData="00000000", isExtra=false, iskey=false, isNull=false,
		iMaxLength=32, isDecimal=false, iIntegralLength=2, iDecimalLength=2, iIndex=11 )
	@ApiModelProperty(value="修改人", example="00000000", position=11)
	//[end]
	protected String sModifieder;

	/**
	 * 修改日期
	 */
	@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")//解决表单提交时字符串时间值错误
	//[start]
	@DataInfo( sDbName="BricksMall", sTableName="Recharge",
		sName="dModifiedDate", sComment="修改日期", isDbField=true, sDbFileType="datetime",
		sDefaultData="", isExtra=false, iskey=false, isNull=false,
		iMaxLength=23, isDecimal=false, iIntegralLength=-1, iDecimalLength=-1, iIndex=12 )
	@ApiModelProperty(value="修改日期", example="", position=12)
	//[end]
	protected Date dModifiedDate;

	/**
	 * 状态(枚举,1:待支付;2:已失效;3:已支付;4:已同步;-1:待支付时删除;-2:已失效时删除;-3:已支付时删除;-4:同步后删除)
	 */
	//[start]
	@DataInfo( sDbName="BricksMall", sTableName="Recharge",
		sName="iState", sComment="状态(枚举,1:待支付;2:已失效;3:已支付;4:已同步;-1:待支付时删除;-2:已失效时删除;-3:已支付时删除;-4:同步后删除)", isDbField=true, sDbFileType="int",
		sDefaultData="1", isExtra=false, iskey=false, isNull=false,
		iMaxLength=100, isDecimal=false, iIntegralLength=2, iDecimalLength=2, iIndex=13 )
	@ApiModelProperty(value="状态(枚举,1:待支付;2:已失效;3:已支付;4:已同步;-1:待支付时删除;-2:已失效时删除;-3:已支付时删除;-4:同步后删除)", example="1", position=13)
	//[end]
	protected Integer iState;

	/**
	 * 序号
	 */
	//[start]
	@DataInfo( sDbName="BricksMall", sTableName="Recharge",
		sName="iIndex", sComment="序号", isDbField=true, sDbFileType="int",
		sDefaultData="1", isExtra=false, iskey=false, isNull=false,
		iMaxLength=100, isDecimal=false, iIntegralLength=2, iDecimalLength=2, iIndex=14 )
	@ApiModelProperty(value="序号", example="1", position=14)
	//[end]
	protected Integer iIndex;

	/**
	 * 版本
	 */
	//[start]
	@DataInfo( sDbName="BricksMall", sTableName="Recharge",
		sName="iVersion", sComment="版本", isDbField=true, sDbFileType="int",
		sDefaultData="1", isExtra=false, iskey=false, isNull=false,
		iMaxLength=100, isDecimal=false, iIntegralLength=2, iDecimalLength=2, iIndex=15 )
	@ApiModelProperty(value="版本", example="1", position=15)
	//[end]
	protected Integer iVersion;

	/**
	 * 记录验证串
	 */
	//[start]
	@DataInfo( sDbName="BricksMall", sTableName="Recharge",
		sName="sRecordKey", sComment="记录验证串", isDbField=true, sDbFileType="varchar",
		sDefaultData="", isExtra=false, iskey=false, isNull=false,
		iMaxLength=32, isDecimal=false, iIntegralLength=2, iDecimalLength=2, iIndex=16 )
	@ApiModelProperty(value="记录验证串", example="", position=16)
	//[end]
	protected String sRecordKey;

	/**
	 * 操作失败次数
	 */
	//[start]
	@DataInfo( sDbName="BricksMall", sTableName="Recharge",
		sName="iErrorCount", sComment="操作失败次数", isDbField=true, sDbFileType="int",
		sDefaultData="0", isExtra=false, iskey=false, isNull=false,
		iMaxLength=100, isDecimal=false, iIntegralLength=2, iDecimalLength=2, iIndex=17 )
	@ApiModelProperty(value="操作失败次数", example="0", position=17)
	//[end]
	protected Integer iErrorCount;

	/**
	 * 取 记录编号
	 * @return String
	 */
	public String getuId() {
		return uId;
	}

	/**
	 * 设置记录编号
	 * @param uId
	 */
	public void setuId(String uId) {
		this.uId = uId;
	}

	/**
	 * 取 顾客编号
	 * @return String
	 */
	public String getsCustomerId() {
		return sCustomerId;
	}

	/**
	 * 设置顾客编号
	 * @param sCustomerId
	 */
	public void setsCustomerId(String sCustomerId) {
		this.sCustomerId = sCustomerId;
	}

	/**
	 * 取 微信公共号
	 * @return String
	 */
	public String getsOpenid() {
		return sOpenid;
	}

	/**
	 * 设置微信公共号
	 * @param sOpenid
	 */
	public void setsOpenid(String sOpenid) {
		this.sOpenid = sOpenid;
	}

	/**
	 * 取 充值订单号
	 * @return String
	 */
	public String getsOrderNo() {
		return sOrderNo;
	}

	/**
	 * 设置充值订单号
	 * @param sOrderNo
	 */
	public void setsOrderNo(String sOrderNo) {
		this.sOrderNo = sOrderNo;
	}

	/**
	 * 取 下单IP
	 * @return String
	 */
	public String getsSpbillCreateIp() {
		return sSpbillCreateIp;
	}

	/**
	 * 设置下单IP
	 * @param sSpbillCreateIp
	 */
	public void setsSpbillCreateIp(String sSpbillCreateIp) {
		this.sSpbillCreateIp = sSpbillCreateIp;
	}

	/**
	 * 取 订单描述
	 * @return String
	 */
	public String getsBody() {
		return sBody;
	}

	/**
	 * 设置订单描述
	 * @param sBody
	 */
	public void setsBody(String sBody) {
		this.sBody = sBody;
	}

	/**
	 * 取 价格(元)
	 * @return Long
	 */
	public BigDecimal getmFund() {
		return mFund;
	}

	/**
	 * 设置 价格(元)
	 * @param mFund
	 */
	public void setmFund(BigDecimal mFund) {
		this.mFund = mFund;
	}

	/**
	 * 取 积分
	 * @return Integer
	 */
	public Integer getiTally() {
		return iTally;
	}

	/**
	 * 设置积分
	 * @param iTally
	 */
	public void setiTally(Integer iTally) {
		this.iTally = iTally;
	}

	/**
	 * 取 备注
	 * @return String
	 */
	public String getsMemo() {
		return sMemo;
	}

	/**
	 * 设置备注
	 * @param sMemo
	 */
	public void setsMemo(String sMemo) {
		this.sMemo = sMemo;
	}

	/**
	 * 取 创建人
	 * @return String
	 */
	public String getsCreator() {
		return sCreator;
	}

	/**
	 * 设置创建人
	 * @param sCreator
	 */
	public void setsCreator(String sCreator) {
		this.sCreator = sCreator;
	}

	/**
	 * 取 创建日期
	 * @return Date
	 */
	public Date getdCreateDate() {
		return dCreateDate;
	}

	/**
	 * 设置创建日期
	 * @param dCreateDate
	 */
	public void setdCreateDate(Date dCreateDate) {
		this.dCreateDate = dCreateDate;
	}

	/**
	 * 取 修改人
	 * @return String
	 */
	public String getsModifieder() {
		return sModifieder;
	}

	/**
	 * 设置修改人
	 * @param sModifieder
	 */
	public void setsModifieder(String sModifieder) {
		this.sModifieder = sModifieder;
	}

	/**
	 * 取 修改日期
	 * @return Date
	 */
	public Date getdModifiedDate() {
		return dModifiedDate;
	}

	/**
	 * 设置修改日期
	 * @param dModifiedDate
	 */
	public void setdModifiedDate(Date dModifiedDate) {
		this.dModifiedDate = dModifiedDate;
	}

	/**
	 * 取 状态(枚举,1:待支付;2:已失效;3:已支付;4:已同步;-1:待支付时删除;-2:已失效时删除;-3:已支付时删除;-4:同步后删除)
	 * @return Integer
	 */
	public Integer getiState() {
		return iState;
	}

	/**
	 * 设置状态(枚举,1:待支付;2:已失效;3:已支付;4:已同步;-1:待支付时删除;-2:已失效时删除;-3:已支付时删除;-4:同步后删除)
	 * @param iState
	 */
	public void setiState(Integer iState) {
		this.iState = iState;
	}

	/**
	 * 取 序号
	 * @return Integer
	 */
	public Integer getiIndex() {
		return iIndex;
	}

	/**
	 * 设置序号
	 * @param iIndex
	 */
	public void setiIndex(Integer iIndex) {
		this.iIndex = iIndex;
	}

	/**
	 * 取 版本
	 * @return Integer
	 */
	public Integer getiVersion() {
		return iVersion;
	}

	/**
	 * 设置版本
	 * @param iVersion
	 */
	public void setiVersion(Integer iVersion) {
		this.iVersion = iVersion;
	}

	/**
	 * 取 记录验证串
	 * @return String
	 */
	public String getsRecordKey() {
		return sRecordKey;
	}

	/**
	 * 设置记录验证串
	 * @param sRecordKey
	 */
	public void setsRecordKey(String sRecordKey) {
		this.sRecordKey = sRecordKey;
	}

	/**
	 * 取 操作失败次数
	 * @return Integer
	 */
	public Integer getiErrorCount() {
		return iErrorCount;
	}

	/**
	 * 设置操作失败次数
	 * @param iErrorCount
	 */
	public void setiErrorCount(Integer iErrorCount) {
		this.iErrorCount = iErrorCount;
	}

	/**
	 * 创建当前'记录验证串'
	 * @param key 加密密钥
	 * @return String 子节点集合
	 */
	public String createRecordKey(String key) {
		StringBuilder sb = new StringBuilder(1000);
		
		sb.append(null != this.uId ? String.valueOf(this.uId) : "").append(";");
		sb.append(null != this.sCustomerId ? String.valueOf(this.sCustomerId) : "").append(";");
		sb.append(null != this.sOpenid ? String.valueOf(this.sOpenid) : "").append(";");
		sb.append(null != this.sOrderNo ? String.valueOf(this.sOrderNo) : "").append(";");
		sb.append(null != this.sSpbillCreateIp ? String.valueOf(this.sSpbillCreateIp) : "").append(";");
		sb.append(null != this.sBody ? String.valueOf(this.sBody) : "").append(";");
		sb.append(null != this.mFund ? MoneyUtil.BigDecimal2String(this.mFund, 2) : "").append(";");
		sb.append(null != this.iTally ? String.valueOf(this.iTally) : "").append(";");
		sb.append(null != this.sCreator ? String.valueOf(this.sCreator) : "").append(";");
		sb.append(null != this.dCreateDate ? TimeUtil.toStr(this.dCreateDate, "YYYY-MM-dd HH:mm:00") : "").append(";");
		sb.append(null != this.sModifieder ? String.valueOf(this.sModifieder) : "").append(";");
		sb.append(null != this.dModifiedDate ? TimeUtil.toStr(this.dModifiedDate, "YYYY-MM-dd HH:mm:00") : "").append(";");
		sb.append(null != this.iState ? String.valueOf(this.iState) : "").append(";");
		sb.append(null != this.iIndex ? String.valueOf(this.iIndex) : "").append(";");
		sb.append(null != this.iVersion ? String.valueOf(this.iVersion) : "").append(";");
		sb.append(key);

		return MD5Util.MD5(sb.toString());
	}
	
	/**
	 * 复制对象
	 * @param source 数据源
	 * @return RechargeBase
	 */
	public static RechargeBase copy(RechargeBase source) {
		if (null == source) {
			return null;
		}
		
		RechargeBase target = new RechargeBase();
		target.setuId(source.getuId());
		target.setsCustomerId(source.getsCustomerId());
		target.setsOpenid(source.getsOpenid());
		target.setsOrderNo(source.getsOrderNo());
		target.setsSpbillCreateIp(source.getsSpbillCreateIp());
		target.setsBody(source.getsBody());
		target.setmFund(source.getmFund());
		target.setiTally(source.getiTally());
		target.setsMemo(source.getsMemo());
		target.setsCreator(source.getsCreator());
		target.setdCreateDate(source.getdCreateDate());
		target.setsModifieder(source.getsModifieder());
		target.setdModifiedDate(source.getdModifiedDate());
		target.setiState(source.getiState());
		target.setiIndex(source.getiIndex());
		target.setiVersion(source.getiVersion());
		target.setsRecordKey(source.getsRecordKey());
		target.setiErrorCount(source.getiErrorCount());

		return target;
	}
	
	/**
	 * 克隆对象
	 * @return RechargeBase
	 */
	public RechargeBase clone() {
		return copy(this);
	}
	
}
